
package com.hitrust.gs.action;

import com.hitrust.gs.bean.GSManufactureBean;
import com.hitrust.gs.dao.GSManufactureDAO;
import com.hitrust.gs.form.ManufactureSetForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;

/**
 * 产品设置操作
 */
public class GSManufactureSetTemporaryAction extends GSBaseAction {

    public String execute(GSBaseForm aForm) throws Exception {
        String auditingValue = aForm.getRequest().getParameter("auditing").trim();
        String message = "";
        if(auditingValue.equals("modify")){
            message = aForm.getRequest().getParameter("messages").trim(); 
        }
        
      
        ManufactureSetForm mf=(ManufactureSetForm) aForm;
        String[] tManufactures = mf.temporary_manufacture;

        GSManufactureDAO tGSManufactureDAO = new GSManufactureDAO();
        for(int i=0;i<tManufactures.length;i++){
            GSManufactureBean product =  tGSManufactureDAO.getManufactureByConcentricityCode(tManufactures[i], "select * from t_product");
            if(product.getAuditing_status().equals("3")){
                aForm.getRequest().setAttribute("exception_desc","产品集中编码为："+tManufactures[i]+"的产品已经是审核不通过，不能再次审核，请确认");
                aForm.getRequest().setAttribute("target", "_self");
                return GSBaseConstants.FORWARD_ERROR;
            }else{                
               if(auditingValue.equals("modify")){
                   tGSManufactureDAO.modifyGSManufactureSetTemporaryAddMessage(tManufactures[i],message); 
               }else{
                  tGSManufactureDAO.modifyGSManufactureSetTemporary(tManufactures[i],auditingValue); 
               }
            }
            
        }

        // 查询条件
        aForm.getRequest().setAttribute("message", "产品信息设置完成！");


        return GSBaseConstants.FORWARD_SUCCESS;

}
}